<template>
	<div>
		<div class="mainBox">
			<!-- 下拉框查询 -->
			<el-form :inline="true" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="110px" class="formBox">
				<el-row :gutter="20">
					<el-col :span="8">
						<el-form-item label="会员姓名" prop="name">
							<el-input placeholder="请输入会员姓名" v-model="ruleForm.name"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="会员账号"  prop="phoneQuery">
							<el-input placeholder="请输入会员账号" v-model="ruleForm.phoneQuery"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item class="secondRow_formItem">
							<el-button type="primary" @click="submitForm('ruleForm')">积分查询</el-button>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</div>
		<div class="tableBox">
			<el-table :data="tableData" style="width:100%" stripe border v-loading="tableLoading">
				<el-table-column prop="memberValue" label="会员姓名" center></el-table-column>
				<el-table-column prop="memberId" label="会员账号" center></el-table-column>
				<el-table-column prop="cumulativeMoney" label="累计消费金额" center></el-table-column>
				<el-table-column prop="cumulativeIntegral" label="累计积分" center></el-table-column>
				<el-table-column prop="surplusIntegral" label="剩余积分" center></el-table-column>
			</el-table>

		</div>
	</div>
</template>

<script>
import {integralEnterLogDetails} from '@/api/user'
export default {
  data() {
    var checkPhone = (rule, value, callback) => {
      if (!value) {
        callback(new Error("手机号不能为空！"));
      } else if (!/^1[3456789]\d{9}$/.test(value)) {
        callback(new Error("手机格式有误"));
      } else {
        callback();
      }
    };
    return {
      ruleForm: {
        name: "",
        phoneQuery: ""
		},
		tableLoading:false,
	  tableData:[],
      rules: {
        phoneQuery: [
          {
            validator: checkPhone,
            trigger: "blur"
          }
        ]
      }
    };
  },
  methods:{
	  submitForm(formName) {
						this.tableLoading=true
						let that=this			
				this.$refs[formName].validate((valid) => {
					if (valid) {
					integralEnterLogDetails({memberId:this.ruleForm.phoneQuery}).then(res=>{
					if(res.code==200){
						let obj=res.data
						let arr=[]
						arr.push(obj)
						this.tableData=arr
						that.tableLoading=false
						
					}else{
						that.$message.error(res.msg)
						that.tableLoading=false
					}
					})
					} else {
						that.tableLoading=false
						return false;
					}
				});
			}
	}
	
};
</script>

<style>
.formBox {
  margin-top: 20px;
}
.tableBox {
		margin: 120px 20px 0 20px;
	}

</style>
